home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8180 < prev    next >
Encoding:
Text File  |  1996-08-05  |  918 b   |  40 lines

  1. Path: news.u-net.com!news
  2. From: charlotte@parmo.u-net.com (Thomas Christensen)
  3. Newsgroups: comp.lang.c++
  4. Subject: How to prototype a class?
  5. Date: Thu, 15 Feb 1996 15:28:46 GMT
  6. Organization: U-NET limited
  7. Message-ID: <4fvjhe$c6o@nuntius.u-net.net>
  8. Reply-To: thc@mailhost.net
  9. NNTP-Posting-Host: parmo.u-net.com
  10. X-Newsreader: Forte Free Agent v0.55
  11.  
  12. Hi All
  13.  
  14. In trying to compile the following code example from the VC4 knowledge
  15. base, I get "error C2653: 'B' : is not a class or namespace name"
  16. on the line with 'friend int B::Func1(A);.
  17.  
  18. class A
  19. {
  20. private:
  21.     int _a;
  22.     friend int B::Func1( A );   //  Grant friend access to one
  23.                                 //   function in class B.
  24. };
  25.  
  26. class B
  27. {
  28. public:
  29.     int Func1( A a ) { return a._a; } //  OK: this is a friend.
  30. };
  31.  
  32. How can I work my way around this problem?
  33.  
  34. Thomas Christensen
  35.  
  36. (Please post and e-mail)
  37. E-mail: thc@mailhost.net
  38. E-mail: thc@mailhost.net
  39.  
  40.